package com.hk.yingmi;

import com.hk.app.utils.YingmiOpenAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
public class YingmiApiClient {

    @Autowired
    private YingmiOpenAPI openAPI;

    @RequestMapping(value = "/tlsGet", produces = "text/html;charset=UTF-8")
    @ResponseBody
    public String sslGet(String path, String params, String flag) {
        if (!path.startsWith("/")) {
            path = "/" + path;
        }

        return openAPI.sslGet(path, params, flag);
    }

    @RequestMapping(value = "/tlsPost", produces = "text/html;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String sslPost(@RequestBody Map<String, String> map) {
        return openAPI.sslPost(map);
    }
}
